package com.library.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter("/*")
public class responseFilter implements Filter {
    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {
        HttpServletResponse httpRes=(HttpServletResponse) response;
        //让业务代码写数据
        chain.doFilter(request, httpRes);

        //加统一开头
        httpRes.setHeader("Response-Time",String.valueOf(System.currentTimeMillis()));
        httpRes.setHeader("Server","LibrarySystem/1.0");
    }

    public void init(FilterConfig filterConfig) throws ServletException {}

    public void destroy() {}

}
